#include <iostream>
#include <cstring>
#include <set>
#include <vector>
#define MAX_PRIME 2750131
using namespace std;

char isp[MAX_PRIME+1];
int id[MAX_PRIME+1];
int Max[MAX_PRIME+1] = {0};
int main()
{

    memset(isp, '1', MAX_PRIME+1);
    for (int i=2; i<=MAX_PRIME; ++i)
    {
        int cnt = i;
        if (i*cnt > MAX_PRIME) break;
        while (i*cnt<=MAX_PRIME)
        {
            isp[i*cnt] = '0';
            ++cnt;
        }
    }

    int pri[200000];
    int cnt = 1;
    for (int i=2; i<=MAX_PRIME; ++i)
    {
        if (isp[i]=='1')
        {
            id[i] = cnt;
            pri[cnt] = i;
            ++cnt;
        }
    }


    for (int i=2; i<=MAX_PRIME; ++i)
    {
        if (isp[i]=='0')
        {
            for (int j=1; j<200000; ++j)
            {
                if (i % pri[j]==0)
                {
                    Max[i] = i / pri[j];
                    break;
                }
            }
        }
    }

    int n;
    cin >> n;
    multiset<int> b;
    for (int i=1; i<=2*n; ++i)
    {
        int inp;
        cin >> inp;
        b.insert(inp);
    }

    vector<int> a;
    while (b.size())
    {
        multiset<int>::iterator it = b.end();
        int mb = *--it;
        if (isp[mb]=='1')
        {
            a.push_back(id[mb]);
            b.erase(it);
            it = b.find(id[mb]);
            b.erase(it);

        }
        if (isp[mb]=='0')
        {
            a.push_back(mb);
            b.erase(it);
            it = b.find(Max[mb]);
            b.erase(it);
        }
    }
    for (unsigned int i=0; i<a.size(); ++i)
    {
        printf("%d ", a[i]);
    }


    return 0;
}
